define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'inform/informlog/index' + location.search,
                    // add_url: 'inform/informlog/add',
                    edit_url: 'inform/informlog/edit',
                    del_url: 'inform/informlog/del',
                    multi_url: 'inform/informlog/multi',
                    import_url: 'inform/informlog/import',
                    table: 'inform_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'uid', title: __('Uid')},
                        {field: 'inform_title', title: __('Inform_title'), operate: 'LIKE'},
                        {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        // {field: 'content', title: __('Content'), operate: 'LIKE'},
                        {field: 'inform_time', title: __('Inform_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_sendto', title: __('Is_sendto'), searchList: {"1":__('待处理'),"2":__('已处理')}, formatter: Table.api.formatter.normal},
                        {field: 'sendto', title: __('Sendto'), operate: 'LIKE'},
                        {field: 'order_id', title: __('Order_id')},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                        {field: 'technician_nickname', title: __('Technician_nickname'), operate: 'LIKE'},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        // {field: 'technician_id', title: __('Technician_id')},
                        // {field: 'store_id', title: __('Store_id')},
                        {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'order.order_sn', title: __('Order.order_sn'), operate: 'LIKE'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
